<template>
	<view class="pageBox">
		<view class="couponInfoBox">
			<view class="couponName">{{dataInfo.integralCommodity.commodityName}}</view>
			<view class="couponQRCodeBox">
				<uqrcode class="QRCode" ref="uqrcode" sizeUnit="rpx" size="330" canvas-id="qrcode" :value="qrCode"
					v-if="qrCode" :options="{ margin: 10 }">
				</uqrcode>
			</view>
			<!-- <view class="storefrontName">蜜雪冰城鳌江店</view> -->
			<!-- <view class="couponEndTime">有效期：{{dataInfo.expirationTime}}</view> -->
		</view>
	</view>
</template>

<script>
	import * as vouchersApi from '@/api/vouchers.js'
	export default {
		data() {
			return {
				infoId: '',
				eliteInfo: {
					userId: ''
				},
				qrCode: '',
				dataInfo: {
					integralCommodity: {
						commodityFile: '',
						commodityName: '',
						integral: '',
						remark: '',
					},
					collectionTime: "",
					createBy: null,
					createTime: null,
					exhibitionCode: "",
					expirationTime: "",
					limits: null,
					remark: null,
					stopCode: "",
					updateBy: null,
					updateTime: null,
					usageTime: null,
					userId: null,
					volumeId: "",
					volumeName: "",
					volumeState: "",
					volumeType: "",
				}
			};
		},
		onLoad(options) {
			console.log(options);
			this.infoId = options.id
		},
		onShow() {
			this.getUserInfo()
		},
		methods: {
			getUserInfo() {
				this.$store.dispatch('userBaseInfo').then(res => {
					this.businessInfo = res.businessInfo
					this.eliteInfo = res.eliteInfo
					const userId = this.eliteInfo.userId || ''
					vouchersApi.vouchersId(this.infoId, userId).then(({
						data
					}) => {
						this.dataInfo = data
						this.qrCode = JSON.stringify({
							vid: data.volumeId,
							uid: data.userId
						})
					})
				})
			},
			getInfo() {
				const userId = this.$store.getters.eliteInfo.userId
				console.log(userId);
				vouchersApi.vouchersId(this.infoId).then(({
					data
				}) => {
					this.dataInfo = data
				})
			},

		}
	}
</script>

<style lang="scss" scoped>
	.pageBox {
		box-sizing: border-box;
		min-height: 100vh;
		background-color: #F4F7FF;
		padding: 30rpx;

		.couponInfoBox {
			background: #FFFFFF;
			border-radius: 16rpx 16rpx 16rpx 16rpx;
			opacity: 1;
			padding: 80rpx 0;
			text-align: center;

			.couponName {
				font-size: 48rpx;
				font-family: PingFang SC, PingFang SC;
				font-weight: 500;
				color: #0138D2;
			}

			.couponQRCodeBox {
				margin: 36rpx 0;
				text-align: center;
				display: flex;
				align-items: center;
				justify-content: center;

				.QRCode {
					width: 330rpx;
					height: 330rpx;
					object-fit: cover;
				}

			}

			.storefrontName {
				font-size: 32rpx;
				font-family: PingFang SC, PingFang SC;
				font-weight: 500;
				color: #000000;
				margin-bottom: 40rpx;
			}

			.couponEndTime {
				font-size: 28rpx;
				font-family: PingFang SC, PingFang SC;
				font-weight: 400;
				color: #666666;
			}

		}
	}
</style>